package com.weathereport.activity;

import com.weathereport.activity.adapter.LocalForecastAdapter;
import com.weathereport.dao.WeatherDAO;
import com.weathereport.entity.Local;

import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.format.Time;
import android.widget.ListView;

public class LocalForecastActivity extends ListActivity {

	private Context ctx;
	private WeatherDAO dao;
	private ListView listView;
	private Time today;
	private Local local;
	private int localId;
	private Intent nav;

	
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		ctx = this;
		
		localId = getIntent().getIntExtra("localId", 0);
		
 		dao = new WeatherDAO(ctx); 		
 		
 		today = new Time(Time.getCurrentTimezone());
		today.setToNow();
				
		local = dao.getLocal(localId);
		
		listView = getListView();		
		setListAdapter((new LocalForecastAdapter(this, local.getForecast())));
				
		// Enable filter feature
		
		listView.setTextFilterEnabled(true); 		
	}
	
	public void goToMain(Context context){
		
		nav = new Intent(ctx, WeatheReportMain.class);
		nav.putExtra("firstRun", false);
		startActivity(nav);
	}
}
